<?php
##############################################
#
#   预约列表
# @ Time : 2017-1-8 - 下午9:20:27
# @ Author : JiangYongWei <1085562810@qq.com>
# @ Encoding : UTF-8 language : PHP
#
##############################################


namespace Admin\Model;

class ApplyModel extends AdminBaseModel{
	/*预约表  */
	protected $tableName = 'apply';	
	
	public function __construct($tableName=''){
		//初始化数据库对象
		if(!empty($tableName)){
			$this -> tableName = $tableName;
		}	
		parent::__construct($this -> tableName);
	}
	
	/**
	 * 获取专家类型列表
	 */
	public function getApplyCategory($name){
            if($name){
			$map['name'] = array('like','%'.$name.'%');
		}
	    $count = M('apply_category')->where($map) ->count();// 查询满足要求的总记录数
	    $Page = new \Think\Page($count, C('listRows'));
	    $show = $Page->show();
	    $result = M('apply_category')->where($map)->order('id asc')->limit($Page->firstRow.','.$Page->listRows)->select();
		return array($result, $show);
	}
	
	/**
	 * 获取一个类型
	 */
	public function getCategoryFind($id){
	    return M('apply_category')->where("id = $id")->find();
	}
	
	/**
	 * 修改专家类型
	 */
	public function editApplyCategory($id, $data){
	    return M('apply_category')->where("id = $id")->save($data);
	    
	}
	
	/**
	* 删除预约
	*/
	public function deleteCategory($id){
		return M('apply_category')->where("id = $id")->delete();
	}
    
	/**
	 * 全选删除预约
	 */
	public function deleteAllMake($idArr) {
	    foreach ($idArr['make_id'] as $k => $v){
	        $this->where("id = $v")->delete();
	    }
	    return true;
	}
	
	
}